<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="../css/demo.css" />
    
    <title>Jslet - 提交所选数据（审核数据）</title>
    <script type="text/javascript" data-main="../config.js" src="../lib/requirejs/require.min.js"></script>
    <script type="text/javascript">
	    require(['dataset/d-submitselected', 'lib/mock/jquery.mockjax', 'mock/order-mock']);
    </script>
</head>
<body>
    <div class="demo-header">
    <h4 id="top">Jslet - 提交所选数据（审核数据）</h4>
	</div>
	<hr />
    <p>订单列表: <button id="btnQuery" class="btn btn-default btn-sm"> 查询 </button>
    <button id="btnAudit" class="btn btn-default btn-sm"> 审核所选 </button>
    <button id="btnCancelAudit" class="btn btn-default btn-sm"> 取消审核所选 </button>
	</p>
	<div data-jslet='type:"DBTable",dataset:"product",hasSelectCol:true' style="width: 100%; height: 200px">
	</div>	

	<div class="demo-desc">
	</div>
	<hr />
	<h4>源码</h4>
    <pre class="prettyprint linenums"><code>
	//创建“订单”数据集
	var fldCfg = [
		{ name: 'state', type: 'S', length: 30, label: 'Audit State', displayWidth: 8},
		{ name: 'auditor', type: 'S', length: 20, label: 'Auditor', displayWidth: 10},
		{ name: 'auditdate', type: 'D', length: 20, label: 'Audit Date', displayFormat: 'yyyy-MM-dd hh:mm:ss'},
		{ name: 'product', type: 'S', length: 30, label: 'Product', displayWidth: 16},
		{ name: 'price', label: 'Price', type: 'N', length: 10, scale: 2, displayFormat: '#,##0.00'},
		{ name: 'quantity', label: 'Quantity', type: 'N', length: 5, displayFormat: '#,##0.00' },
		{ name: 'cost', label: 'Total Cost', type: 'N', length: 12, scale: 2, displayFormat: '#,##0.00', formula:'[price]*[quantity]' }
		];
	var dsOrder = new jslet.data.Dataset({name: 'product', fields: fldCfg});
	dsOrder.queryUrl('/demo/order/findall');
   	jslet.ui.install();
    
    //绑定按钮事件
	$('#btnQuery').click(function() {
		//查询
		dsOrder.query();
	});
	
	$('#btnAudit').click(function() {
		if(!dsOrder.hasSelectedRecords()) {
			jslet.ui.info('请先选择数据，再审核！', null, null, 1000);
			return;
		}
		dsOrder.submitSelected('/demo/order/audit');
	});

	$('#btnCancelAudit').click(function() {
		if(!dsOrder.hasSelectedRecords()) {
			jslet.ui.info('请先选择数据，再取消审核！', null, null, 1000);
			return;
		}
		dsOrder.submitSelected('/demo/order/cancelaudit');
	});
	</code></pre>

    <script type="text/javascript">
       window.LOADER_BASE_URL = "../lib/prettify";
    </script>
    <script type="text/javascript" src="../lib/prettify/run_prettify.js"></script>
		
</body>
</html>
